package edu.netjava.Queue;
/**
 * 
 * @author tan
 * this class is to test the class queue
 *
 */
public class QueueTest {
	
	public static  void main(String args[]){
		
		// initial the class Queue
	 
		Queue que = new Queue();
	
		// input
		java.util.Scanner sca = new java.util.Scanner(System.in);
		String str ;
		boolean isExit = false;
		
		/* 
		 * to deal the input ,to quit when give 'y'
		 */
		 
		while(!isExit){
			System.out.println("Please input elements into the queue:");
			str = sca.next();
			
			//element into the queue
			que.enterQueue(str);
			System.out.println("Do you want to continue?y/n");
			str = sca.next();
						if(str.equalsIgnoreCase("n")){
				isExit = true;
				
			//print the elements in the queue	
				que.printQueue();
			}
		}
		
		/*
		 * to test methods,give you some choice to do
		 * pleases chose
		 */
		isExit = false;
		while(!isExit){
			
			//prompts to users
			System.out.println("please give your choice:"+"A,getHead \n" +
					"B,get and remove the elemenet \n" +
					"C,give the index of the element and get it\n " +
					"Q,exit");
			
			str = sca.next();
			
			//give the detail choices to users
			if(str.equalsIgnoreCase("A")){
				System.out.println(que.getHead());
			}else if(str.equalsIgnoreCase("B")){
				que.removeHead();
			}else if(str.equalsIgnoreCase("C")){
				int index = sca.nextInt();
				System.out.println(que.getQueueElement(index));
			}else if(str.equalsIgnoreCase("Q")){
				System.exit(0);
				System.out.println("Program has been out!");
			}
			
			//whether to continue to the last step
			System.out.println("Continue?y/n");
			str = sca.next();
			if(str.equalsIgnoreCase("n")){
				isExit = true;
			}
		}
		
	}

}
